﻿namespace dPet.Domain.Events.Handlers
{
	using dPet.Domain.Models;
	using dPet.Domain.Repositories;
	using Hangerd.Event;

	public class InventoryAlarmDisabledEventHandler : IDomainEventHandler<InventoryAlarmDisabledEvent>
	{
		private readonly IInventoryAlarmItemRepository _inventoryAlarmItemRepository;

		public InventoryAlarmDisabledEventHandler(IInventoryAlarmItemRepository inventoryAlarmItemRepository)
		{
			_inventoryAlarmItemRepository = inventoryAlarmItemRepository;
		}

		public void Handle(InventoryAlarmDisabledEvent e)
		{
			var product = e.Source as Product;

			_inventoryAlarmItemRepository.RemoveItemsByProductAndAlarmType(product, e.AlarmType);
		}
	}
}
